package com.one.efaimaly.user.presenter;

import android.content.Context;

import com.one.common.config.CMemoryData;
import com.one.common.model.bean.UserInfoBean;
import com.one.common.model.http.callback.ObserverOnResultListener;
import com.one.common.presenter.BaseApiPresenter;
import com.one.common.view.base.BaseActivity;
import com.one.efaimaly.user.model.UserWorkerModel;
import com.one.common.model.bean.UserWorkerBean;
import com.one.efaimaly.user.view.UserInfoView;
import com.one.common.common.user.modle.UserInfoModel;

/**
 * author ：zhulunjun
 * email  ：zhulunjun@qq.com
 * date   ：2018/8/5 下午5:46
 * description ：
 **/
public class UserInfoPresenter extends BaseApiPresenter<UserInfoView, UserInfoModel> {

    public UserInfoPresenter(UserInfoView mView, Context mContext) {
        super(mView, mContext, new UserInfoModel((BaseActivity) mContext));
    }


    public void getUserInfo() {
        mModel.getUserInfo(new ObserverOnResultListener<UserInfoBean>() {
            @Override
            public void onResult(UserInfoBean userInfoBean) {
                if (userInfoBean != null) {
                    CMemoryData.setUserInfo(userInfoBean);
                    mView.setUserInfoView(userInfoBean);
                    getUserWorkerInfo();
                }
            }
        });
    }

    /**
     * 获取师傅信息
     */
    private void getUserWorkerInfo() {
        new UserWorkerModel(mActivity).getUserWorkerInfo(new ObserverOnResultListener<UserWorkerBean>() {
            @Override
            public void onResult(UserWorkerBean userWorkerBean) {
                if (userWorkerBean != null) {
                    mView.setUserWorkerView(userWorkerBean);
                }
            }
        });
    }





}
